package strukturaZamestnanciNepritomnost;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Nepritomnost {

    private String typNepritomnosti;
    private double dlzkaNepritomnosti;
    private Calendar datumCalendar;

    public Nepritomnost(String datum, String typ, double dlzka) throws ParseException {
        final String DATE_FORMAT = "dd.MM.yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        datumCalendar = new GregorianCalendar();
        datumCalendar.setTime(sdf.parse(datum));
        typNepritomnosti = typ;
        dlzkaNepritomnosti = dlzka;
    }

    public Nepritomnost(Calendar c, String typ, double dlzka) {
        datumCalendar = c;
        typNepritomnosti = typ;
        dlzkaNepritomnosti = dlzka;
    }

    public String getDatum() {
        final String DATE_FORMAT = "dd.MM.yyyy";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return sdf.format(datumCalendar.getTime());
    }

    public String getDatumSQL() {
        final String DATE_FORMAT = "yyyy-MM-dd";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return sdf.format(datumCalendar.getTime());
    }

    public String getTyp() {
        return typNepritomnosti;
    }

    public double getDlzka() {
        return dlzkaNepritomnosti;
    }
}
